package com.jz.netthings.analysis.controller;

import com.jz.netthings.analysis.bean.link.NurseLinkProviderStatistics;
import com.jz.netthings.analysis.service.NurseLinkProviderStatisticsService;
import com.jz.netthings.analysis.service.XyDevelopAnalysisService;
import com.jz.netthings.exception.AdscmSystemException;
import com.jz.netthings.support.SimpleCoreResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 血源发展分析统计所有controller
 */
@RestController
@RequestMapping("/adscm/analysis/xyDevelopAnalysis")
public class XyDevelopAnalysisController {


    @Autowired
    XyDevelopAnalysisService xyDevelopAnalysisService;

    @Autowired
    NurseLinkProviderStatisticsService nurseLinkProviderStatisticsService;

    /**
     * 查询某一年的采浆量统计表：某年根据月、轮次、天，统计采浆量
     * @param year 年份，如果为 0 或者Null，则默认当前年
     * @return
     * @throws AdscmSystemException
     */
    @RequestMapping("/selectCollStatisticsByYear")
    public SimpleCoreResponse selectCollStatisticsByYear(Integer year) throws AdscmSystemException {

        return new SimpleCoreResponse("200", "查询成功", xyDevelopAnalysisService.selectCollStatisticsByYear(year));
    }
    /**
     * 查询浆量同期比，查询当前年、当前年的前一年、前两年、前两之前
     * @param year 年份，如果为 0 或者Null，则默认当前年
     * @return
     * @throws AdscmSystemException
     */
    @RequestMapping("/getPulpWeight")
    public SimpleCoreResponse getPulpWeight(Integer year) throws AdscmSystemException {

        return new SimpleCoreResponse("200", "查询成功", xyDevelopAnalysisService.getPulpWeight(year));
    }
    /**
     * 查询返站浆员与返站浆员同期比，当年、去年、前年 三年的数据
     * @param year 年份，如果为 0 或者Null，则默认当前年
     * @return
     * @throws AdscmSystemException
     */
    @RequestMapping("/getFrequencyCount")
    public SimpleCoreResponse getFrequencyCount(Integer year) throws AdscmSystemException {

        return new SimpleCoreResponse("200", "查询成功", xyDevelopAnalysisService.getFrequencyCount(year));
    }
    /**
     * 查询新浆员同期比，当年、去年、前年 三年的数据
     * @param year 年份，如果为 0 或者Null，则默认当前年
     * @return
     * @throws AdscmSystemException
     */
    @RequestMapping("/getNewAndOutProviderCount")
    public SimpleCoreResponse getNewAndOutProviderCount(Integer year) throws AdscmSystemException {

        return new SimpleCoreResponse("200", "查询成功", xyDevelopAnalysisService.getNewAndOutProviderCount(year));
    }

    /**
     * 分页查看今年已献浆未链接浆员
     * @param current
     * @param size
     * @return
     * @throws AdscmSystemException
     */
    @RequestMapping("/getThisYearComedNotLink")
    public SimpleCoreResponse getThisYearComedNotLink(Integer current, Integer size) throws AdscmSystemException {

        return new SimpleCoreResponse("200", "查询成功", xyDevelopAnalysisService.getThisYearComedNotLink(current,size));
    }

    /**
     * 分页查看已链接今年未献浆浆员
     * @param current
     * @param size
     * @return
     * @throws AdscmSystemException
     */
    @RequestMapping("/getLinkedThisYearNotComed")
    public SimpleCoreResponse getLinkedThisYearNotComed(Integer current, Integer size) throws AdscmSystemException {

        return new SimpleCoreResponse("200", "查询成功", xyDevelopAnalysisService.getLinkedThisYearNotComed(current,size));
    }

    //////////////////////////////////////////////////////////////////////////////////////////
    //链接护士统计
    /**
     * 查看所有链接护士及护士链接浆员数量
     * @return
     * @throws AdscmSystemException
     */
    @RequestMapping("/getLinkNursePCount")
    public SimpleCoreResponse getLinkNursePCount() throws AdscmSystemException {

        return new SimpleCoreResponse("200", "查询成功", nurseLinkProviderStatisticsService.getLinkNursePCount());
    }
    /**
     * 根据护士，查询护士链接的综合统计信息
     * @return
     * @throws AdscmSystemException
     */
    @RequestMapping("/getLinkNurseStatistics")
    public SimpleCoreResponse getLinkNurseStatistics(Integer nurseId) throws AdscmSystemException {

        return new SimpleCoreResponse("200", "查询成功", nurseLinkProviderStatisticsService.selectById(nurseId));
    }

    /**
     * 根据护士，查询护士链接的所有浆员类型及浆员数量、根据村落分组的浆员数量
     * @return
     * @throws AdscmSystemException
     */
    @RequestMapping("/getLinkNurseAllTypeProvider")
    public SimpleCoreResponse getLinkNurseAllTypeProvider(Integer nurseId) throws AdscmSystemException {

        return new SimpleCoreResponse("200", "查询成功", nurseLinkProviderStatisticsService.getLinkNurseAllTypeProvider(nurseId));
    }

    /**
     * 根据条件，查询浆员的伦次信息
     * @param nurseId 护士ID
     * @param type 类型
     * @param villName 村落名称
     * @return
     * @throws AdscmSystemException
     */
    @RequestMapping("/getProviderRoundByCondition")
    public SimpleCoreResponse getProviderRoundByCondition(Integer nurseId,String type,String villName) throws AdscmSystemException {

        return new SimpleCoreResponse("200", "查询成功", nurseLinkProviderStatisticsService.getProviderRoundByCondition(nurseId,type,villName));
    }



















    /**
     * 装载护士链接的综合统计信息
     * @return
     * @throws AdscmSystemException
     */
    @RequestMapping("/loadNurseLinkProviderStatistics")
    public SimpleCoreResponse loadNurseLinkProviderStatistics() throws AdscmSystemException {

        nurseLinkProviderStatisticsService.loadNurseLinkProviderStatistics();
        return new SimpleCoreResponse("200", "装载成功", null);
    }


}
